<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .active{
            border: 1px solid red;
        }
    </style>
</head>
<body>
<!--
v-if

设置元素的属性

设置元素的属性(比如:src,title,class)

1. v-bind指令的作用是:为元素绑定属性

2. 完整写法是 v-bind:属性名

3. 简写的话可以直接省略v-bind,只保留 :属性名

4. 需要动态的增删class建议使用对象的方式


-->
<div id="app">
    <img v-bind:src="imgSrc" alt="">
    <br>
    <img :src="imgSrc" :title="imgTitle+'!!!'" :class="isActive?'active':''" @click="toggleActive" alt="">
    <img :src="imgSrc" :title="imgTitle+'!!!'" :class="{active:isActive}" @click="toggleActive" alt="">
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    var app = new Vue({
        el:"#app",
        data:{
            imgSrc:"http://www.itheima.com/images/logo.png",
            imgTitle:"黑马程序员",
            isActive:true
        },
        methods:{
            toggleActive:function() {
               this.isActive = !this.isActive;
            },
        }
    });
</script>
</html>